/************************************************************
 * Project Name         [Thinking_In_Java]
 * File Name            [NotepadFrame.java]
 * Creation Date        [11-Jul-2014]
 * 
 * Copyright© ge.y.yang@gmail.com All Rights Reserved
 * 
 * Work hard, play harder, think big and keep fit
 ************************************************************/
package pkg_02_gui.notepad_V1.ui.main;

import static javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Font;
import java.io.File;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

/**
 * 记事本主面板
 * 
 * @author 不落的太阳(Sean Yang)
 * @version 1.0
 * @since JDK 6
 * 
 */
public class NotepadFrame extends JFrame {

	private static final long serialVersionUID = 1817344891228550244L;

	private final JTextArea textArea = new JTextArea();// 文本框
	private final JLabel statusLabel = new JLabel("按Ctrl+F1获取帮助");// 状态栏
	private final Font defaultFont = new Font("宋体", Font.PLAIN, 15);// 默认字体
	private JPanel toolbarPanel = new JPanel(); // 浮动工具栏面板

	private final File file = null;

	private final NotepadMenuBar menuBar;

	public NotepadFrame(String frameName) {
		super(frameName);

		// 添加浮动工具栏面板
		toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
		this.add(toolbarPanel, BorderLayout.NORTH);

		// 添加文本域
		textArea.setFont(defaultFont);
		JScrollPane scrollPane = new JScrollPane(textArea);
		scrollPane.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_ALWAYS);
		getContentPane().add(scrollPane);

		// 添加菜单栏
		menuBar = new NotepadMenuBar(this, textArea, statusLabel, file);
		setJMenuBar(menuBar);

		// 添加状态栏
		this.add(statusLabel, BorderLayout.SOUTH);

		this.setSize(800, 600);
		setLocationByPlatform(true);

	}

	public JPanel getToolbarPanel() {
		return toolbarPanel;
	}

	public void setToolbarPanel(JPanel toolbarPanel) {
		this.toolbarPanel = toolbarPanel;
	}

}
